home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
hifi.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
40KB
|
1,693 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATUtilities HiFi-Player ** */
/* ** Copright (C) 1993-1994 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ******************************************************************* */
#include "ATUtilities.h"
#include "HiFi.h"
UBYTE *HelpName="AT:Help/HiFiPlayer.help";
#define MAXTITLES 250
#define CATSIZE ((4+(MAXTITLES*128)) + 20000L)
#define CATFILESIZE(x) (4+(x*128))
UBYTE PlayCount[MAXTITLES];
UBYTE anti_error1[4096];
struct Catalog
{
UWORD Entries;
UBYTE Random;
UBYTE Pad;
UBYTE Title[1][128];
} *Catalog,*Cat2;
struct Interrupt MyInt;
UBYTE anti_error2[1000];
struct Library *GfxBase;
struct Library *IntuitionBase;
struct Library *ATUtilitiesBase;
struct Library *AslBase;
struct Library *UtilityBase;
struct Library *GadToolsBase;
extern struct Library *SysBase;
extern struct Library *DOSBase;
struct Task *Task;
struct TextFont *opal;
struct Window *HCWindow;
struct Screen *HCScreen;
struct RastPort *HCRPort;
struct ViewPort *HCViewPort;
struct TagItem *ReqTags;
struct FileRequester *FileReq;
struct WBArg *fargs;
struct Lock *lock;
UBYTE dir[130];
struct NewScreen HCScreenDef=
{
0,210,640,45,2,
0,1,HIRES,CUSTOMSCREEN,
0,0,0,0
};
struct NewWindow HCWindowDef=
{
0,0,640,45,0,1,
0L,BORDERLESS,
0L,0L,0L,0L,0L,
50,50,640,100,
CUSTOMSCREEN
};
LONG PortSignal;
ULONG PortSignalMask;
ULONG WaitSignalMask;
ULONG Signale;
VOID Update();
VOID HiFiControl();
VOID StopSymbol();
VOID WaitSymbol();
VOID PlaySymbol();
VOID ShowPlayer();
VOID ShowSTitle();
VOID ShowVolume();
VOID ShowInfo();
VOID OpenAll();
VOID CloseAll();
VOID TitleEd();
VOID LoadCatalog();
VOID SaveCatalog();
BOOL CheckX();
BOOL AuPrefs();
UWORD rand();
UWORD RT();
UWORD Zufall();
VOID RndStart();
struct MsgPort *Port;
struct Global
{
APTR AslBase;
APTR DOSBase;
APTR IntuitionBase;
APTR GfxBase;
APTR GadToolsBase;
APTR ReservedLibraryBase;
APTR DirArrayPtr;
APTR FileArrayPtr;
APTR PathArrayPtr;
APTR ChkData;
ULONG ChkSize;
UWORD SndNum;
UWORD SndVol;
UWORD SndLBal;
UWORD SndRBal;
UWORD LED;
UWORD Timer;
VOID (* GetListData)();
VOID (* LoadFile)();
VOID (* CopyDir)();
VOID (* CopyFile)();
VOID (* CopyString)();
VOID (* AudioAlloc)();
VOID (* AudioFree)();
VOID (* StartInt)();
VOID (* StopInt)();
VOID (* SongEnd)();
VOID (* CutSuffix)();
VOID (* SetTimer)();
APTR R1,R2,R3;
} Global;
UBYTE anti_error3[4096];
struct DOSSegment
{
BPTR NextSegment;
ULONG RTS;
UBYTE ID[8];
APTR TagArray;
};
struct Tag
{
ULONG Code;
ULONG Data;
} *Tags;
struct DOSSegment *Segmente[200];
BPTR Player[200];
UWORD PlayerCnt;
UBYTE anti_error4[1000];
#define TAG_USER 0x80000000
#define TAG_DONE 0
#define TAG_IGNORE 1
#define DPT_TagBase (ULONG)((ULONG)TAG_USER+(ULONG)((UWORD)'DT'))
#define DPT_InternalPlayer DPT_TagBase+0
#define DPT_CustomPlayer DPT_TagBase+1
#define DPT_RequestDTVersion DPT_TagBase+2
#define DPT_RequestV37 DPT_TagBase+3
#define DPT_PlayerVersion DPT_TagBase+4
#define DPT_PlayerName DPT_TagBase+5
#define DPT_Creator DPT_TagBase+6
#define DPT_Check1 DPT_TagBase+7
#define DPT_Check2 DPT_TagBase+8
#define DPT_ExtLoad DPT_TagBase+9
#define DPT_Interrupt DPT_TagBase+10
#define DPT_Stop DPT_TagBase+11
#define DPT_Config DPT_TagBase+12
#define DPT_UserConfig DPT_TagBase+13
#define DPT_SubSoundRange DPT_TagBase+14
#define DPT_InitPlayer DPT_TagBase+15
#define DPT_EndPlayer DPT_TagBase+16
#define DPT_InitSound DPT_TagBase+17
#define DPT_EndSound DPT_TagBase+18
#define DPT_StartInt DPT_TagBase+19
#define DPT_StopInt DPT_TagBase+20
#define DPT_Volume DPT_TagBase+21
#define DPT_Balance DPT_TagBase+22
#define DPT_Faster DPT_TagBase+23
#define DPT_Slower DPT_TagBase+24
#define DPT_NextPatt DPT_TagBase+25
#define DPT_PrevPatt DPT_TagBase+26
#define DPT_NextSong DPT_TagBase+27
#define DPT_PrevSong DPT_TagBase+28
#define DPT_SubSongTest DPT_TagBase+29
WORD CallCheck1(),CallCheck2();
VOID xGetListData();
VOID xLoadFile();
VOID xCopyDir();
VOID xCopyFile();
VOID xCopyString();
VOID xAudioAlloc();
VOID xAudioFree();
VOID xStartInt();
VOID xStopInt();
VOID xSongEnd();
VOID xCutSuffix();
VOID xSetTimer();
APTR InitPlayer;
APTR EndPlayer;
APTR InitSound;
APTR EndSound;
APTR Interrupt;
APTR StartInt;
APTR StopInt;
APTR Check1;
APTR Check2;
APTR Volume;
UBYTE *mem;
UBYTE *pname;
ULONG size;
UWORD current;
BOOL play;
BOOL ploaded;
UBYTE CurrentVol;
UBYTE pad001;
BOOL Start();
VOID Stop();
VOID LoadAllPlayers();
BOOL LoadPlayer();
VOID UnLoadPlayers();
/* Installationsroutine */
VOID main()
{
register struct Message *msg;
REGISTER LONG i,j,k,l;
REGISTER BOOL bool;
ploaded=FALSE;
OpenAll();
bool=FALSE;
play=FALSE;
if(Catalog->Random==0)
current=0;
else
current=Zufall(Catalog->Entries-1);
if(HiFiPrefs.Control!=0) HiFiControl();
while(bool==FALSE)
{
Signale=Wait(WaitSignalMask);
if(Signale & PortSignalMask)
{
i=Received(Port);
while(i!=0)
{
switch(i)
{
case UTILITY_QUIT:
DisplayBeep(NULL);
if(HCScreen!=NULL) HiFiControl();
bool=TRUE;
break;
case UTILITY_HELP:
Help(HelpName,0);
break;
case UTILITY_INFO:
Stop();
ShowInfo();
break;
case 1100:
if(play==FALSE)
{
current=0;
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1001:
if(play==FALSE)
{
play=Start(current);
if(play==FALSE) Stop();
}
RndStart();
break;
case 1002:
Stop();
RndStart();
play=FALSE;
break;
case 1003:
Stop();
current=0;
play=Start(0);
if(play==FALSE) Stop();
break;
case 1004:
if(Catalog->Entries>0)
{
Stop();
current=Catalog->Entries-1;
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1005:
if(current<MAXTITLES)
{
Stop();
current=current+1;
if(current==Catalog->Entries) current=0;
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1505:
Stop();
msg=GetMsg(Port);
while(msg!=NULL)
{
ReplyMsg(msg);
msg=GetMsg(Port);
}
if(Catalog->Entries>0)
{
if(Catalog->Random!=0)
{
current=(UBYTE)Zufall(Catalog->Entries-1);
if(PlayCount[current]==1)
{
k=0; j=current;
for(i=0;i<Catalog->Entries;i++)
{
if(PlayCount[j]==0)
{
k=1;
current=j;
break;
}
j++;
if(j>=Catalog->Entries) j=0;
}
if(k==0)
{
for(i=0;i<MAXTITLES;i++)
PlayCount[i]=0;
}
}
}
else
{
current=current+1;
if(current>=Catalog->Entries) current=0;
}
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1006:
if(Catalog->Entries>0)
{
Stop();
if(current>0) current=current-1; else current=Catalog->Entries-1;
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1500:
if(Catalog->Entries>0)
{
Stop();
current=(UBYTE)Zufall(Catalog->Entries-1);
if(PlayCount[current]==1)
{
k=0; j=current;
for(i=0;i<Catalog->Entries;i++)
{
if(PlayCount[j]==0)
{
k=1;
current=j;
break;
}
j++;
if(j>=Catalog->Entries) j=0;
}
if(k==0)
{
for(i=0;i<MAXTITLES;i++)
PlayCount[i]=0;
}
}
play=Start(current);
if(play==FALSE) Stop();
}
break;
case 1007:
if(play) Stop();
TitleEd();
play=FALSE;
current=0;
Update();
break;
case 1008:
if(play) Stop();
LoadCatalog(NULL);
if(Catalog->Random==0)
current=0;
else
current=Zufall(Catalog->Entries-1);
if(play==TRUE)
{
play=Start(current);
}
Update();
break;
case 1009:
if(play) Stop();
SaveCatalog();
if(play)
{
play=Start(current);
if(play==FALSE) Stop();
}
Update();
break;
case UTILITY_CALL:
case 1010:
if(play) Stop();
bool=AuPrefs();
if(play)
{
play=Start(current);
if(play==FALSE) Stop();
}
Update();
break;
case 1012:
HiFiControl();
break;
case 1013:
if(CurrentVol<=62) CurrentVol+=2;
Global.SndVol=CurrentVol;
if((play)&&(Volume))
CallVolume();
ShowVolume();
break;
case 1014:
if(CurrentVol>=2) CurrentVol-=2;
Global.SndVol=CurrentVol;
if((play)&&(Volume))
CallVolume();
ShowVolume();
break;
}
i=Received(Port);
}
}
}
Stop();
CloseAll();
}
/* Installationsroutine */
VOID OpenAll()
{
REGISTER UWORD i;
register struct MsgPort *p;
register struct FileHandle *fh;
ATUtilitiesBase=OpenLibrary("at-utilities.library",0L);
if(ATUtilitiesBase==NULL)
{
printf("FEHLER: Kann ATUtilities-Library nicht öffnen.\n");
CloseAll();
}
p=FindPort(HiFiPort);
if(p!=NULL)
{
InfoRequest("ATUtilities HiFi-Player ist schon aktiv.");
CloseAll();
}
if((SysBase->lib_Version<36)||(DOSBase->lib_Version<36))
{
InfoRequest("HiFi-Player benötigt Kickstart 2.0!");
CloseAll();
}
Task=FindTask(NULL);
GfxBase=OpenLibrary("graphics.library",0L);
IntuitionBase=OpenLibrary("intuition.library",0L);
if((GfxBase==NULL)||(IntuitionBase==NULL))
{
CloseAll();
}
AslBase=OpenLibrary("asl.library",0L);
if(AslBase==NULL)
{
InfoRequest("Konnte Asl-Library nicht laden.");
CloseAll();
}
GadToolsBase=OpenLibrary("gadtools.library",0L);
if(GadToolsBase==NULL)
{
InfoRequest("Konnte GadTools-Library nicht laden.");
CloseAll();
}
UtilityBase=OpenLibrary("utility.library",0L);
if(UtilityBase==NULL)
{
InfoRequest("Konnte Utility-Library nicht laden.");
CloseAll();
}
opal=GetOpalFont();
Port=CreatePort(HiFiPort,0L);
if(Port==NULL)
{
ErrorRequest(ERROR_MPORT);
CloseAll();
}
fh=Open(HiFiPrefsName,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&HiFiPrefs,sizeof(struct HiFiPrefs));
Close(fh);
}
Catalog=AllocMem(CATSIZE*2,MEMF_CLEAR|MEMF_PUBLIC);
if(Catalog==NULL)
{
ErrorRequest(ERROR_ALLOC);
CloseAll();
}
Cat2=(ULONG)Catalog+(ULONG)CATSIZE;
ReqTags=AllocateTagItems(8L);
if(ReqTags==NULL)
{
InfoRequest("Kein Speicher für Tag-Items!\n");
CloseAll();
}
ReqTags[0].ti_Tag=ASL_Pattern;
ReqTags[1].ti_Tag=ASL_FuncFlags;
ReqTags[1].ti_Data=FILF_MULTISELECT|FILF_PATGAD;
ReqTags[2].ti_Tag=ASL_Hail;
ReqTags[2].ti_Data="HiFi-Player - Dateiauswahl";
ReqTags[3].ti_Tag=ASL_Width;
ReqTags[3].ti_Data=500;
ReqTags[4].ti_Tag=ASL_Height;
ReqTags[4].ti_Data=200;
ReqTags[5].ti_Tag=ASL_TopEdge;
ReqTags[5].ti_Data=0;
ReqTags[6].ti_Tag=ASL_LeftEdge;
ReqTags[6].ti_Data=80;
ReqTags[7].ti_Tag=TAG_DONE;
FileReq=AllocAslRequest(ASL_FileRequest,NULL);
if(FileReq==NULL)
{
InfoRequest("Kein Speicher für ASL-Requester!");
CloseAll();
}
PortSignal=Port->mp_SigBit;
PortSignalMask=(1L<<PortSignal);
WaitSignalMask=PortSignalMask;
ChangeTaskPri(10);
Global.AslBase=AslBase;
Global.DOSBase=DOSBase;
Global.IntuitionBase=IntuitionBase;
Global.GfxBase=GfxBase;
Global.GadToolsBase=GadToolsBase;
Global.SndNum=0;
Global.SndVol=HiFiPrefs.Volume;
CurrentVol=HiFiPrefs.Volume;
Global.SndLBal=HiFiPrefs.LBal;
Global.SndRBal=HiFiPrefs.RBal;
Global.LED=1;
Global.Timer=SysBase->VBlankFrequency;
Global.GetListData=(VOID *)xGetListData;
Global.LoadFile=(VOID *)xLoadFile;
Global.CopyDir=(VOID *)xCopyDir;
Global.CopyFile=(VOID *)xCopyFile;
Global.CopyString=(VOID *)xCopyString;
Global.AudioAlloc=(VOID *)xAudioAlloc;
Global.AudioFree=(VOID *)xAudioFree;
Global.StartInt=(VOID *)xStartInt;
Global.StopInt=(VOID *)xStopInt;
Global.SongEnd=(VOID *)xSongEnd;
Global.CutSuffix=(VOID *)xCutSuffix;
Global.SetTimer=(VOID *)xSetTimer;
MyInt.is_Node.ln_Succ=NULL;
MyInt.is_Node.ln_Pred=NULL;
MyInt.is_Node.ln_Pri=0;
MyInt.is_Node.ln_Type=NT_INTERRUPT;
MyInt.is_Node.ln_Name="hifiplayer-ghettoblaster.interrupt";
MyInt.is_Data=&Global;
LoadCatalog(&HiFiPrefs.DefaultCatalog);
}
/* Alle Player aus Liste laden */
VOID LoadAllPlayers()
{
REGISTER BOOL bool;
if(ploaded==FALSE)
{
bool=LoadPlayer("AT:HiFi-System/Player/StarTrekker4AM");
if(bool==FALSE)
{
MultiRequest("Player \"StarTrekker4AM\" wird unbedingt zun Prog-",
"rammstart benötigt, ist aber nicht vorhanden!",
"Okay",0L);
CloseAll();
}
LoadPlayer("AT:HiFi-System/Player/IFF-SMUS");
LoadPlayer("AT:HiFi-System/Player/IFF-8SVX");
LoadPlayer("AT:HiFi-System/Player/MarkII");
LoadPlayer("AT:HiFi-System/Player/JamCracker");
LoadPlayer("AT:HiFi-System/Player/fc1.3");
LoadPlayer("AT:HiFi-System/Player/fc1.4");
LoadPlayer("AT:HiFi-System/Player/SaPlayer");
ploaded=TRUE;
}
}
/* Programmende */
VOID CloseAll()
{
UnLoadPlayers();
if(HCScreen!=NULL) HiFiControl();
if(Port) DeletePort(Port);
if(ReqTags) FreeTagItems(ReqTags);
if(FileReq) FreeAslRequest(FileReq);
if(Catalog) FreeMem(Catalog,CATSIZE*2);
if(ATUtilitiesBase) CloseLibrary(ATUtilitiesBase);
if(GfxBase) CloseLibrary(GfxBase);
if(IntuitionBase) CloseLibrary(IntuitionBase);
if(UtilityBase) CloseLibrary(UtilityBase);
if(GadToolsBase) CloseLibrary(GadToolsBase);
if(AslBase) CloseLibrary(AslBase);
exit(0);
}
/* Katalog laden */
VOID LoadCatalog(name)
UBYTE *name;
{
UBYTE str[10];
REGISTER UWORD i;
register struct FileHandle *fh;
RndStart();
if(name==NULL)
{
ReqTags[0].ti_Data="#?.cat";
ReqTags[1].ti_Data=FILF_PATGAD;
if(AslRequest(FileReq,ReqTags))
{
strcpy(&dir,FileReq->rf_Dir);
i=strlen(&dir)-1;
if((dir[i]!=':')&&(dir[0]!=0x00)) { dir[i+1]='/'; dir[i+2]=0x00; }
strcat(&dir,FileReq->rf_File);
name=&dir;
} else name=NULL;
}
if(name!=NULL)
{
fh=Open(name,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&str,8);
if(!(strncmp(&str,"HIFI-CAT",8)))
{
for(i=0;i<MAXTITLES;i++)
{
Catalog->Title[i][0]=0x00;
PlayCount[i]=0;
}
Read(fh,Catalog,CATSIZE);
}
else InfoRequest("Datei ist kein Titelkatalog!");
Close(fh);
}
else
{
MultiRequest("Katalog konnte nicht geöffnet werden:",
name,"Okay",NULL);
}
}
}
/* Katalog laden */
VOID SaveCatalog()
{
REGISTER UWORD i;
register struct FileHandle *fh;
ReqTags[0].ti_Data="#?.cat";
ReqTags[1].ti_Data=FILF_PATGAD|FILF_SAVE;
if(AslRequest(FileReq,ReqTags))
{
strcpy(&dir,FileReq->rf_Dir);
i=strlen(&dir)-1;
if((dir[i]!=':')&&(dir[0]!=0x00)) { dir[i+1]='/'; dir[i+2]=0x00; }
strcat(&dir,FileReq->rf_File);
fh=Open(&dir,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,"HIFI-CAT",8);
Write(fh,Catalog,CATFILESIZE(Catalog->Entries));
Close(fh);
}
else
{
MultiRequest("Katalog konnte nicht erstellt werden:",
&dir,"Okay",NULL);
}
}
}
/* Information */
struct InfoItem ii1=
{
0,0
};
struct InfoItem ii2=
{
1,1,
"Service",
"Haben Sie Anregungen oder",
"Verbesserungswünsche?",
"",
"Senden Sie eine PM (Persönliche Mitteilung)",
"an T.DREIBHOLZ in folgenden Mailboxen:",
"",
"Carrier: 02261/75835",
"Apogee: 02262/68614",
"",
"oder schreiben Sie an:",
"",
"Thomas Dreibholz",
"Molbachweg 7",
"D-51674 Wiehl"
};
struct Info info=
{
2,
&ii1,
&ii2
};
VOID ShowInfo()
{
ExtInformationBox(NULL,
"ATUtilities HiFi-Player - Information",
"$VER: HiFi-Player - Version 4.0",
"Copyright (C) 1993-1994 by",
"Thomas Dreibholz",
"All rights reserved.",
"AT:Icons/HiFi",&info);
}
/* Routinen zur Kommunikation mit den Player-Modulen */
#asm
public _xGetListData
_xGetListData:
move.l _mem,a0
move.l _size,d0
rts
public _xAudioAlloc
_xAudioAlloc:
clr.l d0
rts
public _xLoadFile
_xLoadFile:
clr.l d0
rts
public _xAudioFree
_xAudioFree:
rts
public _xStartInt
_xStartInt:
rts
public _xStopInt
_xStopInt:
rts
#endasm
VOID xCopyDir()
{
}
VOID xCopyFile()
{
}
VOID xCopyString()
{
}
VOID xSetTimer()
{
}
VOID xCutSuffix()
{
}
/* Songende erreicht */
VOID xSongEnd()
{
geta4();
Utility(HiFiPort,1505);
}
/* Assembler-Aufrufe für Player-Funktionen */
#asm
public _CallInitPlayer
_CallInitPlayer:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _InitPlayer,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallEndPlayer
_CallEndPlayer:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _EndPlayer,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallStartInt
_CallStartInt:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _StartInt,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallStopInt
_CallStopInt:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _StopInt,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallInitSound
_CallInitSound:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _InitSound,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallEndSound
_CallEndSound:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _EndSound,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallVolume
_CallVolume:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _Volume,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallCheck1
_CallCheck1:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _Check1,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _CallCheck2
_CallCheck2:
movem.l d1-d7/a0-a6,-(sp)
move.l #_Global,a5
move.l _Check2,a0
jsr (a0)
movem.l (sp)+,d1-d7/a0-a6
rts
public _FilterOn
_FilterOn:
bclr #1,$bfe001
rts
public _FilterOff
_FilterOff:
bset #1,$bfe001
rts
#endasm
/* Wiedergabe starten */
BOOL Start(num)
UWORD num;
{
LONG i,j;
BOOL okay,bool;
struct FileHandle *fh;
Global.AslBase=AslBase;
Global.DOSBase=DOSBase;
Global.IntuitionBase=IntuitionBase;
Global.GfxBase=GfxBase;
Global.GadToolsBase=GadToolsBase;
Global.SndNum=0;
Global.SndVol=HiFiPrefs.Volume;
CurrentVol=HiFiPrefs.Volume;
Global.SndLBal=HiFiPrefs.LBal;
Global.SndRBal=HiFiPrefs.RBal;
Global.LED=1;
Global.Timer=SysBase->VBlankFrequency;
Global.GetListData=(VOID *)xGetListData;
Global.LoadFile=(VOID *)xLoadFile;
Global.CopyDir=(VOID *)xCopyDir;
Global.CopyFile=(VOID *)xCopyFile;
Global.CopyString=(VOID *)xCopyString;
Global.AudioAlloc=(VOID *)xAudioAlloc;
Global.AudioFree=(VOID *)xAudioFree;
Global.StartInt=(VOID *)xStartInt;
Global.StopInt=(VOID *)xStopInt;
Global.SongEnd=(VOID *)xSongEnd;
Global.CutSuffix=(VOID *)xCutSuffix;
Global.SetTimer=(VOID *)xSetTimer;
MyInt.is_Node.ln_Succ=NULL;
MyInt.is_Node.ln_Pred=NULL;
MyInt.is_Node.ln_Pri=0;
MyInt.is_Node.ln_Type=NT_INTERRUPT;
MyInt.is_Node.ln_Name="hifiplayer-ghettoblaster.interrupt";
MyInt.is_Data=&Global;
if(Catalog->Title[num][0]==0x00) return(FALSE);
WaitSymbol();
if(ploaded==FALSE) LoadAllPlayers();
ShowSTitle();
okay=FALSE;
InitPlayer=0L;
EndPlayer=0L;
InitSound=0L;
EndSound=0L;
Interrupt=0L;
StartInt=0L;
StopInt=0L;
Check1=0L;
Check2=0L;
Volume=0L;
printf("START: %s\n",&Catalog->Title[num]);
fh=Open(&Catalog->Title[num],MODE_OLDFILE);
if(fh!=NULL)
{
Seek(fh,0,OFFSET_END);
size=Seek(fh,0,OFFSET_BEGINNING);
printf(" << ALLOC=%ld %ld>>\n",size,AvailMem(MEMF_CHIP|MEMF_LARGEST)/1024);
mem=AllocMem(size,MEMF_CHIP|MEMF_PUBLIC);
if(mem!=NULL)
{
Read(fh,mem,size);
Global.ChkData=mem;
Global.ChkSize=size;
Global.DirArrayPtr="DF2:";
Global.FileArrayPtr="Strings.smus";
Global.PathArrayPtr=&Catalog->Title[num];
bool=CheckX();
if(bool==FALSE)
{
for(j=0;j<PlayerCnt;j++)
{
Tags=Segmente[j]->TagArray;
Check1=GetTagData(DPT_Check1,NULL,Tags);
Check2=GetTagData(DPT_Check2,NULL,Tags);
if(Check1!=NULL)
{
i=CallCheck1();
if(i==0) { bool=TRUE; break; }
}
if(Check2!=NULL)
{
i=CallCheck2();
if(i==0) { bool=TRUE; break; }
}
if((Check1==NULL)&&(Check2==NULL))
{ bool=TRUE; break; }
}
pname=GetTagData(DPT_PlayerName,"Unbekannt",Tags);
}
if(bool==TRUE)
{
ShowPlayer();
InitPlayer=GetTagData(DPT_InitPlayer,NULL,Tags);
EndPlayer=GetTagData(DPT_EndPlayer,NULL,Tags);
InitSound=GetTagData(DPT_InitSound,NULL,Tags);
EndSound=GetTagData(DPT_EndSound,NULL,Tags);
Interrupt=GetTagData(DPT_Interrupt,NULL,Tags);
StartInt=GetTagData(DPT_StartInt,NULL,Tags);
StopInt=GetTagData(DPT_StopInt,NULL,Tags);
Check1=GetTagData(DPT_Check1,NULL,Tags);
Check2=GetTagData(DPT_Check2,NULL,Tags);
Volume=GetTagData(DPT_Volume,NULL,Tags);
i=0; if(InitPlayer) i=CallInitPlayer();
if(i==0)
{
PlaySymbol();
if((StartInt!=NULL)&&(StopInt!=NULL))
{
CallStartInt();
okay=TRUE;
}
else if((InitSound!=NULL)&&(EndSound!=NULL)&&(Interrupt!=NULL))
{
MyInt.is_Code=Interrupt;
CallInitSound();
AddIntServer(5,&MyInt);
okay=TRUE;
}
Global.SndVol=CurrentVol;
if(Volume) CallVolume();
PlayCount[current]=1;
}
}
}
else
{
printf("--- OUT OF MEMORY ---\n%ld Bytes required!\n",size);
}
Close(fh);
}
return(okay);
}
/* Wiedergabe beenden */
VOID Stop()
{
StopSymbol();
pname=NULL;
ShowPlayer();
if(mem!=NULL)
{
if((StartInt!=NULL)&&(StopInt!=NULL))
{
CallStopInt();
}
else if((InitSound!=NULL)&&(EndSound!=NULL)&&(Interrupt!=NULL))
{
RemIntServer(5,&MyInt);
CallEndSound();
}
if(EndPlayer) CallEndPlayer();
FilterOn();
printf(" << FREE=%ld %ld>>\n",size,AvailMem(MEMF_CHIP|MEMF_LARGEST)/1024);
FreeMem(mem,size);
mem=NULL;
}
}
/* Player-Modul laden */
BOOL LoadPlayer(name)
UBYTE *name;
{
if(PlayerCnt<199)
Player[PlayerCnt]=LoadSeg(name);
if(Player[PlayerCnt]!=NULL)
{
Segmente[PlayerCnt]=BADDR(Player[PlayerCnt]);
PlayerCnt++;
return(TRUE);
}
else
{
printf("Player \"%s\" ist nicht vorhanden!!!\n",name);
}
return(FALSE);
}
/* Alle Module entfernen */
VOID UnLoadPlayers()
{
REGISTER UWORD i;
if(PlayerCnt>0)
{
for(i=0;i<PlayerCnt;i++)
{
UnLoadSeg(Player[i]);
}
}
}
/* Play-Symbol im Kontrolldisplay */
VOID PlaySymbol()
{
if(HiFiPrefs.Filter!=0) FilterOn(); else FilterOff();
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,35,5,50,35);
SetAPen(HCRPort,3);
Move(HCRPort,40,12);
Draw(HCRPort,40,32);
Draw(HCRPort,80,22);
Draw(HCRPort,40,12);
}
}
/* Warte-Symbol im Kontrolldisplay */
VOID WaitSymbol()
{
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,35,5,50,35);
SetAPen(HCRPort,3);
Move(HCRPort,40,22);
Draw(HCRPort,80,22);
}
}
/* Stop-Symbol im Kontrolldisplay */
VOID StopSymbol()
{
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,35,5,50,35);
SetAPen(HCRPort,3);
Move(HCRPort,40,12);
Draw(HCRPort,40,32);
Draw(HCRPort,80,32);
Draw(HCRPort,80,12);
Draw(HCRPort,40,12);
}
}
/* Titel im Kontrolldisplay */
VOID ShowSTitle()
{
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,90,5,520,16);
SetAPen(HCRPort,3);
WriteMText(HCRPort,100,16,520,&Catalog->Title[current]);
}
}
/* Player im Kontrolldisplay */
VOID ShowPlayer()
{
if(HCScreen!=NULL)
{
DrawCNBorder(HCWindow,90,24,520,16);
if(pname!=NULL)
{
SetAPen(HCRPort,3);
WriteMText(HCRPort,100,35,520,pname);
}
}
}
/* Lautstärke im Kontrolldisplay */
VOID ShowVolume()
{
REGISTER UWORD v;
if(HCScreen!=NULL)
{
SetAPen(HCRPort,0);
RectFill(HCRPort,616,6,629,39);
v=(CurrentVol*33)/64;
SetAPen(HCRPort,3);
RectFill(HCRPort,616,39-v,629,39);
}
}
/* Display updaten */
VOID Update()
{
if(HCScreen!=NULL)
{
ScreenToFront(HCScreen);
ShowSTitle();
ShowPlayer();
RndStart();
}
}
/* Kontrolldisplay */
VOID HiFiControl()
{
if(HCScreen==NULL)
{
HCScreen=OpenScreen(&HCScreenDef);
if(HCScreen!=NULL)
{
HCWindowDef.Screen=HCScreen;
HCWindow=OpenWindow(&HCWindowDef);
if(HCWindow!=NULL)
{
HCRPort=HCWindow->RPort;
HCViewPort=ViewPortAddress(HCWindow);
SetRGB4(HCViewPort,0,7,5,8);
SetRGB4(HCViewPort,1,13,13,13);
SetRGB4(HCViewPort,2,2,2,2);
SetRGB4(HCViewPort,3,15,15,5);
SetFont(HCRPort,opal);
ShowSTitle();
ShowPlayer();
DrawCNBorder(HCWindow,615,5,15,35);
if(play) PlaySymbol(); else StopSymbol();
ShowVolume();
return;
}
}
}
if(HCWindow) CloseWindow(HCWindow);
if(HCScreen) CloseScreen(HCScreen);
HCScreen=NULL;
}
/* Ausgabe-Einstellungen */
BOOL AuPrefs()
{
UBYTE *defCat,*pdir,*vol,*lbal,*rbal,str[10];
REGISTER UWORD i,j;
REGISTER ULONG Class;
REGISTER BOOL bool,ende;
register struct Window *win;
register struct RastPort *rp;
register struct IntuiMessage *msg;
register struct Gadget *gad;
struct Gadget *filter,*astart,*aswait,*hctrl;
register struct FileHandle *fh;
bool=FALSE;
win=CreateStdWindow("HiFi-Player - Ausgabe-Einstellungen",
75,75,450,138,
CLOSEWINDOW|GADGETUP,
ACTIVATE|WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,opal);
CreateBoolGadget(win,10,15,155,12,"Einstellungen Okay",1);
CreateBoolGadget(win,170,15,155,12,"Programm beenden",2);
CreateBoolGadget(win,335,15,50,12,"Info",3);
CreateBoolGadget(win,390,15,50,12,"Hilfe",4);
WriteText(rp,15,40,"Titel-Katalog bei Programmstart laden:");
defCat=CreateStringGadget(win,10,44,430,12,&HiFiPrefs.DefaultCatalog,127,5);
SelectStdFPen(rp);
WriteText(rp,15,70,"Verzeichnis mit Player-Modulen:");
pdir=CreateStringGadget(win,10,74,430,12,&HiFiPrefs.PlayerDir,127,5);
if(HiFiPrefs.Filter!=0)
filter=CreateSToggleGadget(win,10,90,150,12,"Audio-Filter",6);
else
filter=CreateNToggleGadget(win,310,90,130,12,"Audio-Filter",6);
if(HiFiPrefs.AutoPlaying!=0)
astart=CreateSToggleGadget(win,10,90,150,12,"Auto-Start",7);
else
astart=CreateNToggleGadget(win,10,90,150,12,"Auto-Start",7);
if(HiFiPrefs.AutoPlayingWait!=0)
aswait=CreateSToggleGadget(win,10,105,150,12,"60 Sek. warten",8);
else
aswait=CreateNToggleGadget(win,10,105,150,12,"60 Sek. warten",8);
if(HiFiPrefs.Control!=0)
hctrl=CreateSToggleGadget(win,175,90,130,12,"Kontrolldisplay",12);
else
hctrl=CreateNToggleGadget(win,175,90,130,12,"Kontrolldisplay",12);
sprintf(&str,"%ld",HiFiPrefs.Volume);
vol=CreateIntegerGadget(win,310,105,130,10,&str,3,10);
WriteText(rp,180,113,"Lautstärke:");
WriteText(rp,180,128,"Balance:");
sprintf(&str,"%ld",HiFiPrefs.LBal);
lbal=CreateIntegerGadget(win,310,121,60,10,&str,3,10);
sprintf(&str,"%ld",HiFiPrefs.RBal);
rbal=CreateIntegerGadget(win,380,121,60,10,&str,3,10);
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GTGetIMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
GTReplyIMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
switch(gad->GadgetID)
{
case 1:
fh=Open(HiFiPrefsName,MODE_NEWFILE);
if(fh!=NULL)
{
i=atol(vol);
if(i>64) i=64;
HiFiPrefs.Volume=i;
i=atol(lbal);
if(i>64) i=64;
HiFiPrefs.LBal=i;
i=atol(rbal);
if(i>64) i=64;
HiFiPrefs.RBal=i;
if(hctrl->Flags & SELECTED) HiFiPrefs.Control=1; else HiFiPrefs.Control=0;
if(filter->Flags & SELECTED) HiFiPrefs.Filter=1; else HiFiPrefs.Filter=0;
if(astart->Flags & SELECTED) HiFiPrefs.AutoPlaying=1; else HiFiPrefs.AutoPlaying=0;
if(aswait->Flags & SELECTED) HiFiPrefs.AutoPlayingWait=1; else HiFiPrefs.AutoPlayingWait=0;
strcpy(&HiFiPrefs.DefaultCatalog,defCat);
strcpy(&HiFiPrefs.PlayerDir,pdir);
Write(fh,&HiFiPrefs,sizeof(struct HiFiPrefs));
Close(fh);
}
ende=TRUE;
break;
case 2:
ende=bool=TRUE;
break;
case 3:
ShowInfo();
break;
case 4:
Help(HelpName,0);
break;
}
break;
}
}
DeleteStdWindow(win);
}
return(bool);
}
/* Titeleditor */
VOID TitleEd()
{
UBYTE show[10];
UBYTE select[MAXTITLES];
REGISTER UBYTE StdPen;
REGISTER UWORD i,j,k;
REGISTER ULONG Class;
REGISTER BOOL ende,bool;
register struct Window *win;
register struct RastPort *rp;
register struct IntuiMessage *msg;
register struct Gadget *gad,*prop,*rnd;
register struct PropInfo *pi;
win=CreateStdWindow("HiFi-Player - Titeleditor",
25,25,580,167,
CLOSEWINDOW|GADGETUP,
WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|ACTIVATE);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,GetOpalFont());
CreateBoolGadget(win,10,15,165,12,"Einstellungen okay",1);
CreateBoolGadget(win,210,15,150,12,"Titel hinzufügen",2);
CreateBoolGadget(win,370,15,150,12,"Titel löschen",3);
CreateBoolGadget(win,525,15,45,12,"Neu",9);
if(Catalog->Random!=0)
rnd=CreateSToggleGadget(win,10,150,560,12,"Titelwahl durch Zufallszahlen",7466);
else
rnd=CreateNToggleGadget(win,10,150,560,12,"Titelwahl durch Zufallszahlen",7466);
if(Catalog->Entries<=10) j=1; else j=Catalog->Entries-10;
prop=CreatePropGadget(win,545,30,25,115,0,0,0,65535/j,4);
pi=prop->SpecialInfo;
SelectStdFPen(rp);
StdPen=rp->FgPen;
for(i=0;i<Catalog->Entries;i++) select[i]=StdPen;
for( ;i<MAXTITLES;i++) select[i]=0;
for(i=0;i<10;i++) show[i]=i;
i=32; k=0;
for(j=1000;j<1010;j++)
{
CreateMinGadget(win,11,i,528,12,j);
WriteMText(rp,15,i+8,530,&Catalog->Title[k]);
i+=11; k++;
}
DrawNBorder(win,10,30,530,115);
k=0;
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GTGetIMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
GTReplyIMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
switch(gad->GadgetID)
{
case 1:
ende=TRUE;
break;
case 2:
ReqTags[0].ti_Data="#?";
ReqTags[1].ti_Data=FILF_PATGAD|FILF_MULTISELECT;
if((AslRequest(FileReq,ReqTags)))
{
j=FileReq->rf_NumArgs;
if(j>0)
{
fargs=FileReq->rf_ArgList;
while(j--)
{
if(Catalog->Entries<MAXTITLES)
{
lock=fargs->wa_Lock;
NameFromLock(lock,&dir,80);
i=strlen(&dir)-1;
if(dir[i]!=':') { dir[i+1]='/'; dir[i+2]=0x00; }
strcpy(&Catalog->Title[Catalog->Entries],&dir);
strcat(&Catalog->Title[Catalog->Entries],fargs->wa_Name);
Catalog->Entries++;
} else DisplayBeep(NULL);
fargs++;
}
for(i=0;i<Catalog->Entries;i++) select[i]=StdPen;
for( ;i<MAXTITLES;i++) select[i]=0;
for(i=0;i<10;i++) show[i]=i;
i=32;
DrawCNBorder(win,10,30,530,115);
for(k=0;k<10;k++)
{
if(k<Catalog->Entries)
{
WriteMText(rp,15,i+8,530,&Catalog->Title[k]);
i+=11;
} else break;
}
if(Catalog->Entries<=10) j=1; else j=Catalog->Entries-10;
ModifyProp(prop,win,NULL,
PROPBORDERLESS|FREEVERT|AUTOKNOB,
0,0,0,65535/j);
}
}
break;
case 7466:
if(rnd->Flags & SELECTED) Catalog->Random=1; else Catalog->Random=0;
break;
case 9:
bool=MultiRequest("Wollen Sie wirklich einen neuen",
"Katalog erstellen?",
"Ja, Erstellen","Nein, Abbruch");
if(bool==TRUE)
{
bool=MultiRequest("Wollen Sie eventuelle Änderungen im aktuellen",
"Titelkatalog abspeichern oder verwerfen?",
"Abspeichern","Verwerfen");
if(bool==TRUE) SaveCatalog();
k=0;
DrawCNBorder(win,10,30,530,115);
for(i=0;i<Catalog->Entries;i++) select[i]=StdPen;
for( ;i<MAXTITLES;i++) select[i]=0;
for(i=0;i<10;i++) show[i]=i;
for(i=0;i<MAXTITLES;i++) Catalog->Title[i][0]=0x00;
Catalog->Entries=0;
ModifyProp(prop,win,NULL,
PROPBORDERLESS|FREEVERT|AUTOKNOB,
0,0,0,65535);
}
break;
case 3:
bool=MultiRequest("Wollen Sie wirklich alle gewählten",
"Titel aus dem Katalog löschen?",
"Ja, Löschen","Nein, Abbruch");
if(bool==TRUE)
{
j=0;
for(i=0;i<Catalog->Entries;i++)
{
if(select[i]!=3)
{
strcpy(&Cat2->Title[j],&Catalog->Title[i]); j++;
}
}
Cat2->Entries=j;
for( ;j<MAXTITLES;j++) Cat2->Title[j][0]=0x00;
CopyMem(Cat2,Catalog,CATSIZE);
DrawCNBorder(win,10,30,530,115);
for(i=0;i<Catalog->Entries;i++) select[i]=StdPen;
for( ;i<MAXTITLES;i++) select[i]=0;
for(i=0;i<10;i++) show[i]=i;
i=32;
for(k=0;k<10;k++)
{
if(k<Catalog->Entries)
{
WriteMText(rp,15,i+8,530,&Catalog->Title[k]);
i+=11;
} else break;
}
if(Catalog->Entries<=10) j=1; else j=Catalog->Entries-10;
ModifyProp(prop,win,NULL,
PROPBORDERLESS|FREEVERT|AUTOKNOB,
0,0,0,65535/j);
}
break;
case 4:
if(Catalog->Entries>10)
{
j=pi->VertPot/(65535/(Catalog->Entries-10));
if(j!=k)
{
k=j;
DrawCNBorder(win,10,30,530,115);
for(i=0;i<10;i++)
{
show[i]=k+i;
SetAPen(rp,select[show[i]]);
WriteMText(rp,15,40+(i*11),530,&Catalog->Title[k+i]);
}
}
}
break;
default:
if((gad->GadgetID>=1000)&&(gad->GadgetID<1010))
{
j=gad->GadgetID-1000;
if(select[show[j]]!=0)
{
if(select[show[j]]!=3)
select[show[j]]=3;
else
select[show[j]]=StdPen;
SetAPen(rp,select[show[j]]);
WriteMText(rp,15,40+(j*11),530,&Catalog->Title[show[j]]);
}
}
break;
}
break;
}
}
DeleteStdWindow(win);
}
}
/* Konvertierung zu StarTrekker4AM */
BOOL CheckX()
{
Tags=Segmente[0]->TagArray;
if(size>=0x43b)
{
if(mem[0x438]=='M')
if(mem[0x439]=='.')
if(mem[0x43a]=='K')
if(mem[0x43b]=='.')
{
pname="Konvertierung von NoiseTracker zu StarTrekker4AM";
return(TRUE);
}
if(mem[0x438]=='F')
if(mem[0x439]=='L')
if(mem[0x43a]=='T')
if(mem[0x43b]=='4')
{
pname="Konvertierung von StarTrekker zu StarTrekker4AM";
return(TRUE);
}
}
return(FALSE);
}
/* Zufallszahl ermitteln */
UWORD Zufall(max)
UWORD max;
{
REGISTER UWORD z;
z=rand();
return(z % max);
}
/* Startwert für Zufallszahlengenerator */
VOID RndStart()
{
srand(RT() % 10);
}
/* Startwert holen */
#asm
public _RT
_RT:
move.w $dff006,d0
ext.l d0
rts
#endasm